package com.powernode.common.utils;

import com.alibaba.fastjson2.JSONObject;
import jakarta.servlet.http.HttpServletResponse;

import java.io.PrintWriter;
import java.net.http.HttpResponse;

public class ResponseUtil {
    public static void WriteJson(HttpServletResponse response, Object data){
        response.setContentType("application/json;charset=utf-8");
        PrintWriter writer = null;
        try {
            writer = response.getWriter();
            writer.write(JSONObject.toJSONString(data));
            writer.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            writer.close();
        }
    }
}
